# 1.input() 和 int()
age = int(input("Enter your age: "))
print(age)
print(type(age)) # 获取 age 的类型

height = input("Enter your height: ")
print(height)
print(type(height)) # 默认输入的是 str 类型


# 2. while 循环
message = ""
while message != 'quit':
    message = input("Enter your message: ")
    print(message)

# 3. 使用标记
active = True
while active:
    message = input("Enter your message: ")
    if message == 'quit':
        active = False
    else:
        print(message)

# 4.break 和 continue
active = True
while active:
    message = input("Enter your message: ")
    if message == 'quit':
        break
    elif message == 'q':
        continue
    else:
        print(message)


# 5.删除包含特定值的所有列表元素
pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']
print(pets)
while 'cat' in pets:
    pets.remove('cat')
print(pets)


# 6.使用用户输入来填充字典
responses = {}
# 设置一个标志，指出调查是否继续
polling_active = True
while polling_active:
    # 提示输入被调查者的名字和回答
    name = input("\nWhat is your name? ")
    response = input("Which mountain would you like to climb someday? ")

    # 将答卷存储在字典中
    responses[name] = response

    # 看看是否还有人要参与调查
    repeat = input("Would you like to let another person respond? (yes/ no) ")
    if repeat == 'no':
        polling_active = False

# 调查结束，显示结果
print("\n--- Poll Results ---")
for name, response in responses.items():
    print(name + " would like to climb " + response + ".")